package msfgui;

/**
 *
 * @author scriptjunkie
 */
public class AutorouteOptionsDialog extends OptionsDialog {

    /** Creates new form AutorouteOptionsDialog */
    public AutorouteOptionsDialog(MainFrame parent, boolean modal) {
        super(parent.getFrame(), "Autoroute Options", modal);
        initComponents();
		try{
			ipField.setText("192.168.1.1/24");
		}catch(NullPointerException nex){
		}
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        addRouteButton = new javax.swing.JRadioButton();
        deleteRouteButton = new javax.swing.JRadioButton();
        subnetLabel = new javax.swing.JLabel();
        ipField = new javax.swing.JTextField();
        okButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        buttonGroup1.add(addRouteButton);
        addRouteButton.setSelected(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(AutorouteOptionsDialog.class);
        addRouteButton.setText(resourceMap.getString("addRouteButton.text")); // NOI18N
        addRouteButton.setName("addRouteButton"); // NOI18N

        buttonGroup1.add(deleteRouteButton);
        deleteRouteButton.setText(resourceMap.getString("deleteRouteButton.text")); // NOI18N
        deleteRouteButton.setName("deleteRouteButton"); // NOI18N

        subnetLabel.setText(resourceMap.getString("subnetLabel.text")); // NOI18N
        subnetLabel.setName("subnetLabel"); // NOI18N

        ipField.setText(resourceMap.getString("ipField.text")); // NOI18N
        ipField.setName("ipField"); // NOI18N

        okButton.setText(resourceMap.getString("okButton.text")); // NOI18N
        okButton.setName("okButton"); // NOI18N
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(addRouteButton)
                        .addGap(18, 18, 18)
                        .addComponent(deleteRouteButton))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(subnetLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ipField, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE))
                    .addComponent(okButton, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(addRouteButton)
                    .addComponent(deleteRouteButton))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(subnetLabel)
                    .addComponent(ipField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(okButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

	private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
		if(addRouteButton.isSelected())
			command = "autoroute -s " + ipField.getText();
		else
			command = "autoroute -d -s " + ipField.getText();
		setVisible(false);
		dispose();
	}//GEN-LAST:event_okButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton addRouteButton;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton deleteRouteButton;
    private javax.swing.JTextField ipField;
    private javax.swing.JButton okButton;
    private javax.swing.JLabel subnetLabel;
    // End of variables declaration//GEN-END:variables

}
